import random
import json
from ronglian_sms_sdk import SmsSDK
def send_sms(mobile, datas, tid=1):
    try:
        RONGLIANYUN_CONFIG = {
            "accId": '2c94811c946f6bfb0195c1c208c6364c',  # 对应：ACCOUNT SID
            "accToken": '1a0fde4436424d6484454c1bdddafee5',  # 对应：AUTH TOKEN
            "appId": '2c94811c946f6bfb0195c1c20a793653',  # 对应：AppID(默认)
            "reg_tid": 1,       # 注册短信验证码的模板ID，测试阶段固定为1
            "sms_expire": 60,  # 短信有效期，单位：秒(s)，这是真正的超时时间，注意和datas=("3456",2,)中第二个参数进行换算，保持一致
            "sms_interval": 60,  # 短信发送的冷却时间，单位：秒(s)
        }
        sdk = SmsSDK(RONGLIANYUN_CONFIG.get("accId"), RONGLIANYUN_CONFIG.get("accToken"), RONGLIANYUN_CONFIG.get("appId"))
        resp = sdk.sendMessage(str(tid), mobile, datas)
        response = json.loads(resp)
        return response.get("statusCode") == "000000"
    except Exception as e:
        print(e)
